package org.study.clickhouse.mybatis.boot.controller;

import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import org.study.clickhouse.mybatis.boot.model.User;
import org.study.clickhouse.mybatis.boot.service.UserService;

import java.util.List;

/**
 * 类的描述
 *
 * @author Administrator
 * @date 2021-05-24
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserService userService;

    @RequestMapping
    public List<User> selectAll() {
        List<User> selectAll = userService.selectAll();
        return selectAll;
    }

    @RequestMapping("/{id}")
    public User selectByPrimaryKey(@PathVariable("id") Long id) {
        User select = userService.selectByPrimaryKey(id);
        return select;
    }

    @RequestMapping("/{pageNum}/{pageSize}")
    public PageInfo<User> selectByPrimaryKey(@PathVariable("pageNum") Integer pageNum, @PathVariable("pageSize") Integer pageSize) {
        PageInfo<User> pageInfo = userService.doSelectPageInfo(pageNum, pageSize);
        return pageInfo;
    }
}
